package com.only.common.util;

import cn.hutool.core.bean.BeanUtil;
import cn.hutool.core.bean.copier.CopyOptions;

/**
 * @author only
 * @date 2023/11/27
 * @description
 */
public class BeanCopyUtil {
    /**
     * 将 src 非空的属性值 copy 到 tar
     * @param src
     * @param tar
     * @param <T>
     */
    public static <T> void copyNotNullProperty(T src, T tar, String... ignoreProperties) {
        CopyOptions opt = new CopyOptions()
            .setIgnoreNullValue(true)
            .setIgnoreProperties(ignoreProperties);

        BeanUtil.copyProperties(src, tar, opt);
    }
}
